package com.coolw.data.migrate.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 数据迁移类型枚举定义
 *
 * @author coolw
 * @date 2024/2/6 14:36
 */
@Getter
@AllArgsConstructor
public enum MigrateTypeEnum {

    BEFORE_DAY("1", "迁移多少天之前的数据（不包含当天）"),
    BETWEEN_DATE("2", "按日期范围迁移（包含开始日期和结束日期）"),
    SPECIFIED_DATE("3", "按指定日期迁移"),
    FIXED_SIZE("4", "按固定大小迁移（根据主键升序）");

    private final String code;
    private final String desc;

    public static MigrateTypeEnum getEnum(String code) {
        return Arrays.stream(values())
                .filter(r -> Objects.equals(r.getCode(), code))
                .findFirst()
                .orElse(null);
    }
}
